﻿#include "cc_arr.h"
#include "cc_math.h"

int __cdecl cc_arrFindBiggest( 
	int arr[], 
	int arrCnt 
	)
{
	int maxNum = arr[0];
	int i = 1;
	for(; i < arrCnt; ++i)
	{
		if(arr[i] > maxNum)
			maxNum = arr[i];
	}
	return maxNum;
}

int __cdecl cc_arrFindBiggestEx(
	int arr[],
	int arrCnt
	)
{
	if(arrCnt == 1)
		return arr[0];
	if(arrCnt == 2)
		return max(arr[0], arr[1]);

	return max(arr[0], cc_arrFindBiggestEx(arr + 1, arrCnt - 1));
}

int __cdecl cc_arrFindSmallest( 
	int arr[], 
	int arrCnt 
	)
{
	int minNum = arr[0];
	int i = 1;
	for(; i < arrCnt; ++i)
	{
		if(arr[i] < minNum)
			minNum = arr[i];
	}
	return minNum;
}

int __cdecl cc_arrFindEqualsNum( 
	int arr[],
	int arrCnt, 
	int number 
	)
{
	int i = 0;
	for(; i < arrCnt; ++i)
	{
		if(arr[i] == number)
			return i;
	}
	return -1;
}
